require("../../../models/Swiper");
const mongoose = require("mongoose");
const express = require("express");
const router = express.Router();
const HomeConfigModel = require("../../../models/HomeConfig");
const middleware_auth = require("../../../middleware/auth");
const assert = require("http-assert");
const { resData } = require("../../../utils/format");
const middleware_permission = require("../../../middleware/permission");
module.exports = app => {
    /**
     * @apiGroup 小程序端/首页
     * @api {get}  获取首页配置
     */
    router.get("/getHomeConfig", async (req, res) => {
        const findResult = await HomeConfigModel.find().populate(["swipers","icons","hotSearches"]);
        assert(findResult && findResult.length, 400, "未找到首页配置");
        res.send(resData(findResult[0]));
    });

    app.use("/web/api/home", router);
};
